package edu.arizona.sista.learn.model.holding;

import java.util.ArrayList;
import java.util.List;

import edu.arizona.sista.learn.model.interest.Head;
import edu.arizona.sista.learn.model.motion.Track;
import edu.arizona.sista.learn.util.Utils.ActorName;

public class Person extends SpatialThing{
	public String _partID;
	public List<SpatialThing> _bodyParts;
	public double[][] _gaze; //3D gaze vector location + coordinate
	public List<Track> _tracks;
	
	public Person(ActorName name, String partID) {
		super(name.toString());
		_partID = partID;
		_bodyParts = new ArrayList<SpatialThing>();
		_tracks = new ArrayList<Track>();
	}
	
	public Person(int id, String label) {
		super(id, label);
		_partID = label;
		_bodyParts = new ArrayList<SpatialThing>();
		_tracks = new ArrayList<Track>();
	}
	
	public void addBodyPart(SpatialThing bodyPart){
		_bodyParts.add(bodyPart);
	}
	
	public void setId(int id) {
		_id = id;
	}
	
	@Override
	public String getVariableName() {
		return _label;
	}
	
	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("isa(" + getVariableName() + ", Person)\n");
		for(SpatialThing part : _bodyParts)
			if (part instanceof Hand)
				sb.append("physicalParts(" + getVariableName() + ", " + part.getVariableName() + ")\n");
		return sb.toString();
	}

	public void setGaze(double[][] gaze) {
		_gaze = gaze;
	}

	public double getHandArea() {
		double result = 0;
		for (SpatialThing s: _bodyParts) if (s instanceof Hand) result += s.area();
		return result / 2;
	}

	public double getHeadArea() {
		double result = 0;
		for (SpatialThing s: _bodyParts) if (s instanceof Head) result += s.area();
		return result;
	}

	public void addTrack(int frame, double[] pos) {
		_tracks.add(new Track(frame, pos));		
	}
}
